<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: DynamicScaffoldResourceTestHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">DynamicScaffoldResourceTestHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/dynamic_scaffold_resource_test_helper_rb.html">
                lib/dynamic_scaffold_resource_test_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Basic starting point tests for the standard CRUD controller actions.
Include in your functional test and then set @singular_name =
&#8216;resourcename&#8217; in your setup method, as this is evaled to get
the AR classname, the named_routes, and the instance name of the controller
assigned variable. See <a
href="../../test/dynamic_scaffold_resource_test.rb">../test/dynamic_scaffold_resource_test.rb</a>
for a sample of usage. Currently fairly brittle and mostly useful for
testing the plugin itself. It will fail if models have any
validates_presence_of, for instance.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000001">test_included</a>&nbsp;&nbsp;
      <a href="#M000006">test_should_create_resource</a>&nbsp;&nbsp;
      <a href="#M000008">test_should_destroy_resource</a>&nbsp;&nbsp;
      <a href="#M000005">test_should_get_edit</a>&nbsp;&nbsp;
      <a href="#M000002">test_should_get_index</a>&nbsp;&nbsp;
      <a href="#M000003">test_should_get_new</a>&nbsp;&nbsp;
      <a href="#M000004">test_should_get_show</a>&nbsp;&nbsp;
      <a href="#M000007">test_should_update_resource</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000001" class="method-detail">
        <a name="M000001"></a>

        <div class="method-heading">
          <a href="#M000001" class="method-signature">
          <span class="method-name">test_included</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
These tests were included and run, checks proper inclusion.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000001-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 10</span>
10:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_included</span>
11:     <span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">true</span>
12:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">test_should_create_resource</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 35</span>
35:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_create_resource</span>
36:     <span class="ruby-identifier">resource_class</span> = <span class="ruby-identifier">eval</span>(<span class="ruby-ivar">@singular_name</span>.<span class="ruby-identifier">camelize</span>)
37:     <span class="ruby-identifier">old_count</span> = <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">count</span>
38:     <span class="ruby-identifier">post</span> <span class="ruby-identifier">:create</span>, <span class="ruby-ivar">@singular_name</span>.<span class="ruby-identifier">to_sym</span> =<span class="ruby-operator">&gt;</span> { }
39:     <span class="ruby-identifier">assert_equal</span> <span class="ruby-identifier">old_count</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>, <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">count</span>
40:     <span class="ruby-comment cmt">#assert_redirected_to resource_path(assigns(:resource)</span>
41:     <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">eval</span>(<span class="ruby-node">&quot;#{@singular_name}_path(assigns(:#{@singular_name}))&quot;</span>)
42:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">test_should_destroy_resource</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 50</span>
50:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_destroy_resource</span>
51:     <span class="ruby-identifier">resource_class</span> = <span class="ruby-identifier">eval</span>(<span class="ruby-ivar">@singular_name</span>.<span class="ruby-identifier">camelize</span>)
52:     <span class="ruby-identifier">old_count</span> = <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">count</span>
53:     <span class="ruby-identifier">delete</span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
54:     <span class="ruby-identifier">assert_equal</span> <span class="ruby-identifier">old_count</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">count</span>
55:     
56:     <span class="ruby-comment cmt">#assert_redirected_to resources_path</span>
57:     <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">eval</span>(<span class="ruby-node">&quot;#{@singular_name.pluralize}_path&quot;</span>)
58:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000005" class="method-detail">
        <a name="M000005"></a>

        <div class="method-heading">
          <a href="#M000005" class="method-signature">
          <span class="method-name">test_should_get_edit</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000005-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 30</span>
30:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_get_edit</span>
31:     <span class="ruby-identifier">get</span> <span class="ruby-identifier">:edit</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
32:     <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:success</span>
33:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">
          <a href="#M000002" class="method-signature">
          <span class="method-name">test_should_get_index</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 14</span>
14:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_get_index</span>
15:     <span class="ruby-identifier">get</span> <span class="ruby-identifier">:index</span>
16:     <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:success</span>
17:     <span class="ruby-identifier">assert</span> <span class="ruby-identifier">assigns</span>(<span class="ruby-ivar">@singular_name</span>.<span class="ruby-identifier">pluralize</span>)
18:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">
          <a href="#M000003" class="method-signature">
          <span class="method-name">test_should_get_new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 20</span>
20:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_get_new</span>
21:     <span class="ruby-identifier">get</span> <span class="ruby-identifier">:new</span>
22:     <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:success</span>
23:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">
          <a href="#M000004" class="method-signature">
          <span class="method-name">test_should_get_show</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 25</span>
25:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_get_show</span>
26:     <span class="ruby-identifier">get</span> <span class="ruby-identifier">:show</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
27:     <span class="ruby-identifier">assert_response</span> <span class="ruby-identifier">:success</span>
28:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">test_should_update_resource</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File lib/dynamic_scaffold_resource_test_helper.rb, line 44</span>
44:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_should_update_resource</span>
45:     <span class="ruby-identifier">put</span> <span class="ruby-identifier">:update</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-ivar">@singular_name</span>.<span class="ruby-identifier">to_sym</span> =<span class="ruby-operator">&gt;</span> { }
46:     <span class="ruby-comment cmt">#assert_redirected_to resource_path(assigns(:resource)</span>
47:     <span class="ruby-identifier">assert_redirected_to</span> <span class="ruby-identifier">eval</span>(<span class="ruby-node">&quot;#{@singular_name}_path(assigns(:#{@singular_name}))&quot;</span>)
48:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>